Skip to content

London | 26-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd - #1607

Open
HM-127BTY wants to merge 6 commits into
CodeYourFuture:mainfrom
HM-127BTY:Sprint-3---2-practice-tdd
Open

London | 26-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd#1607
HM-127BTY wants to merge 6 commits into
CodeYourFuture:mainfrom
HM-127BTY:Sprint-3---2-practice-tdd

Conversation

@HM-127BTY

@HM-127BTY HM-127BTY commented Aug 5, 2026

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Added testing and code, starting with writing a test before adding code.

put in code using "if" function.
@HM-127BTY HM-127BTY added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 5, 2026
@HM-127BTY HM-127BTY changed the title London | 25-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd London | 26-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd Aug 5, 2026
@hackertainment hackertainment added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 7, 2026

@hackertainment hackertainment Aug 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon missing in line 8 and line 11.

fun fact: In the original design of JavaScript, there was no semicolon, but it has been added later on - so that nowadays JS programmers generally follow the practice of adding semicolon.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done that fix

Comment thread Sprint-3/2-practice-tdd/count.test.js Outdated
Comment on lines +20 to +33
test("should count multiple occurrences of a character", () => {
const str = "aaa aa";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(5);
});

test("should count multiple occurrences of a character with random characters", () => {
const str = "ajhyabhaakaka";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(6);
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two cases looks quite similar, they both have random characters in the middle of str, and they both start with char, and they both end with char.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not to sure what is ment here, I did do some adjustments

Comment on lines 34 to +44
// Scenario: No Occurrences
// Given the input string `str`,
// And a character `char` that does not exist within `str`.
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of `char` were found.
test("should return 0 with no occurrence of the character", () => {
const str ="abcd";
const char = "e";
const count = countChar(str, char);
expect(count).toEqual(0);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be one more boundary case making char has no occurrence in str. Can you think of that special case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wracked my brain for this one and hit a blank, and advice would be great

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question requires to also handle 2nd and 3rd etc. Since the question itself may not be quite clear about that, you may clarify in slack channel. Thanks.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will ask on there and if needed update the code with it. ^_^

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the question requires to also handle 2nd and 3rd etc, then there will be more test cases.

@hackertainment hackertainment left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good start, and your written code is generally correct. Just need to design more unique test cases to cover all possible scenarios. Also, there are two more files to complete as well. Keep it up :-)

@hackertainment hackertainment added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 7, 2026
@HM-127BTY

Copy link
Copy Markdown
Author

I see in my haste I missed the two files, I have now done those and other fixes aswell, just waiting to see the response on Slack for that one test on the 2nd and 3rds needed or not.

@hackertainment

hackertainment commented Aug 14, 2026

Copy link
Copy Markdown

If there is no reply in Slack, I would still encourage you to code the 2nds and 3rds because:

  1. other trainees did that
  2. there is no harm for you to practice more on coding (I acknowledge that you might have time limitation and working on this course may feel busy or tired sometimes).
  3. Just let me know in case you would like to leave it for the future, so that I can mark this PR as completed (after you made further changes on other files I added with new comments.

Thank you for your great effort, and please keep it up :-)

@HM-127BTY

Copy link
Copy Markdown
Author

I have done that, I now have the code done for the 1 2 and 3, I have also added in tests for negative numbers and hopefully have it done for all numbers. ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants